/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Servlets;


import java.sql.Connection;
import java.sql.DriverManager;
import java.util.Calendar;

/**
 *
 * @author Jose
 */
public class Conexion_DB 
{
    Connection conn = null;
    String url = "jdbc:mysql://localhost:3306/";
    String dbnombre = "edushare";
    String driver = "com.mysql.jdbc.Driver";
    String dbadmin = "root";
    String dbpassadmin = "admin";
    
    public Connection GetConexion()
    {
        return this.conn;
    }
    
    public void setConexion(Connection conn) 
    {
        this.conn = conn;
    }
    
    public void Conectar()
    {
         try
         {
               Class.forName(driver); 
               conn = (Connection) DriverManager.getConnection(url+dbnombre, dbadmin, dbpassadmin);
               
                if(GetConexion() != null)
                {
                    System.out.println("Conexion Exitosa!");
                }
                else
                {
                    System.out.println("Conexion Fallida!");               
                }
         }
         catch (Exception e)
         {
                
         }
    }
    
    public String ObtenerFechaActual()
    {
        Calendar fecha = Calendar.getInstance();
        String fechaActual=fecha.get(Calendar.YEAR) + "-" + (fecha.get(Calendar.MONTH)+1) + "-" + fecha.get(Calendar.DATE);

        return fechaActual;
    }
}
